package map;

import java.util.*;

public class MapTest5 {
    public static void main(String[] args) {
        // 随机80名同学选择4个景点
        List<String> data = new ArrayList<>();
        String[] selects = {"A", "B", "C", "D"};
        Random r = new Random();
        for (int i = 1; i < 80; i++) {
            int index = r.nextInt(4);
            data.add(selects[index]);
        }
        System.out.println(data);
        // 统计结果
        Map<String, Integer> result = new HashMap<>();
        for (String s : data) {
            if (result.containsKey(s)){
                // 说明景点存入过，其值+1，重新存入
                result.put(s, result.get(s) + 1);
            }else{
                result.put(s, 1);
            }
        }
        System.out.println(result);
    }
}
